import {Injectable, Injector} from '@angular/core';
import {Constant} from '@core/constant';
import {_HttpClient, SettingsService} from '@delon/theme';
import {MyHttpClient} from '../MyHttpClient';

@Injectable()
export class spListService {
  get cnt(): Constant {
    return this.injector.get(Constant);
  }

  constructor(
    private injector: Injector,
    private http: _HttpClient,
    private myHttp: MyHttpClient,
    public setting: SettingsService,
  ) {
  }

  /**
   * 分页获取供应商
   */
  list(): string {
    return `${this.cnt.baseUrl}/rest/sapLfa1Controller/list/` + this.setting.user.username;
  }


  /**
   * 分页获取物料凭证
   */
  listekbe(id): string {
    return `${this.cnt.baseUrl}/rest/sapReceiveController/list/` + this.setting.user.username;
  }
  /**
   * 分页获取物料凭证
   */
  listjyxq(id): string {
    return `${this.cnt.baseUrl}/rest/qmBuseController/listqmresult/` + this.setting.user.username;
  }
  /**
   * 分页获取发货数据
   */
  listfh(id): string {
    return `${this.cnt.baseUrl}/rest/sapEkpoFhController/list/` + this.setting.user.username;
  }
  /**
   * 分页获取批次数据
   */
  listbatch(id): string {
    return `${this.cnt.baseUrl}/rest/sapPoBatchController/list/` + this.setting.user.username;
  }
  listplanbatch(id): string {
    return `${this.cnt.baseUrl}/rest/sapPoBatchController/listplan/` + this.setting.user.username;
  }
  getall(bukrs){
    return this.http.get(`${this.cnt.baseUrl}/rest/sapLfa1Controller/fromhana/` + bukrs+"/"+ this.setting.user.username);
    // return this.http.get(`${this.cnt.baseUrl}/rest/sapLfa1Controller/` + bukrs);


  }
//获取采购订单
  getekpo(lifnr,ebeln){
    return this.http.get(`${this.cnt.baseUrl}/rest/sapEkpoController/fromhana/` + this.setting.user.username+"?lifnrno="+lifnr+"&ebeln="+ebeln);
    // return this.http.get(`${this.cnt.baseUrl}/rest/sapLfa1Controller/` + bukrs);


  }

//获取物料凭证
  getekbe(lifnr){
    return this.http.get(`${this.cnt.baseUrl}/rest/sapReceiveController/fromhana/` + this.setting.user.username+"?lifnrno="+lifnr);
    // return this.http.get(`${this.cnt.baseUrl}/rest/sapLfa1Controller/` + bukrs);


  }


  uploadpc(): string {
    return `${this.cnt.baseUrl}/rest/sapPoBatchController/uploadexcel?username=` + this.setting.user.username;
  }

  uploadpcplan(): string {
    return `${this.cnt.baseUrl}/rest/sapPoBatchController/uploadplanexcel?username=` + this.setting.user.username;
  }
  uploadfh(): string {
    return `${this.cnt.baseUrl}/rest/sapEkpoFhController/uploadexcel?username=` + this.setting.user.username;
  }
  /**
   * 获取产品
   * @param id
   */
  getlfa1detail(id) {
    return this.http.get(`${this.cnt.baseUrl}/rest/sapLfa1Controller/` + id);
  }

  /**
   * 修改产品
   * @param product
   */
  editLfa1(product) {
    return this.http.put(
      `${this.cnt.baseUrl}/rest/sapLfa1Controller/${product.id}`,
      product,
    );
  }


  uploadcarinfo(): string {
    return `${this.cnt.baseUrl}/rest/fxjDhImpController/uploadexcel?username=` + this.setting.user.username;
  }


  getpostasklistall() {

    return `${this.cnt.baseUrl}/rest/posXjtaskController/list/` + this.setting.user.username;


  }

  getposfilelist(id) {
    return this.http.get(`${this.cnt.baseUrl}/rest/posXjtaskController/filelist/` + id);
  }


}
